package com.ybb.production.controller;

import com.ybb.production.domain.GarmentProductionProcessConfig;
import com.ybb.production.service.IGarmentProductionProcessConfigService;
import com.yubb.common.annotation.Log;
import com.yubb.common.core.controller.BaseController;
import com.yubb.common.core.domain.AjaxResult;
import com.yubb.common.core.page.TableDataInfo;
import com.yubb.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工序配置Controller
 *
 * @author dengjie
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/production/processConfig")
@Api(tags = "工序配置")
public class GarmentProductionProcessConfigController extends BaseController {
    @Autowired
    private IGarmentProductionProcessConfigService garmentProductionProcessConfigService;

    /**
     * 查询工序配置列表
     */
    @RequiresPermissions("production:processConfig:list")
    @GetMapping("/list")
    @ApiOperation(value = "查询工序配置列表")
    public TableDataInfo<GarmentProductionProcessConfig> list(GarmentProductionProcessConfig garmentProductionProcessConfig) {
        startPage();
        List<GarmentProductionProcessConfig> list = garmentProductionProcessConfigService.selectGarmentProductionProcessConfigList(garmentProductionProcessConfig);
        return getDataTable(list);
    }


    /**
     * 新增工序配置
     */
    @RequiresPermissions("production:processConfig:add")
    @Log(title = "工序配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation(value = "新增工序配置")
    public AjaxResult add(@RequestBody GarmentProductionProcessConfig garmentProductionProcessConfig) {
        return toAjax(garmentProductionProcessConfigService.insertGarmentProductionProcessConfig(garmentProductionProcessConfig));
    }

    /**
     * 修改工序配置
     */
    @RequiresPermissions("production:processConfig:edit")
    @Log(title = "工序配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ApiOperation(value = "修改工序配置")
    public AjaxResult edit(@RequestBody GarmentProductionProcessConfig garmentProductionProcessConfig) {
        return toAjax(garmentProductionProcessConfigService.updateGarmentProductionProcessConfig(garmentProductionProcessConfig));
    }

    /**
     * 删除工序配置
     */
    @RequiresPermissions("production:processConfig:remove")
    @Log(title = "工序配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除工序配置")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(garmentProductionProcessConfigService.deleteGarmentProductionProcessConfigByIds(ids));
    }
}
